//
//  MyLotteryViewController.swift
//  lottery
//
//  Created by admin on 16/2/3.
//  Copyright © 2016年 jin. All rights reserved.
//

import UIKit

class MyLotteryViewController: JinBaseTableViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.navigationItem.title = "设置"
        
        let group1 = SettingGroup()
        group1.settings.append(Setting(title: "推送和提醒", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow"), block: {
            [unowned self] in
            let controller = PushAndRemindController()
            controller.navigationItem.title = "推送和提醒"
            self.navigationController?.pushViewController(controller, animated: true)
        }))
        
        group1.settings.append(Setting(title: "摇一摇机选", titleImage: UIImage(imageLiteral: "handShake"), accessory: UISwitch()))
        group1.settings.append(Setting(title: "声音和效果", titleImage: UIImage(imageLiteral: "handShake"), accessory: UISwitch()))
        self.settings.append(group1)
        let group2 = SettingGroup()
        group2.settings.append(Setting(title: "检查版本更新", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow"), block: {
                [unowned self] in
                let hud = MBProgressHUD.showHUDAddedTo(self.tableView, animated: true)
                hud.label.text = "正在检查更新"
                let time = dispatch_time(DISPATCH_TIME_NOW, Int64(UInt64(2) * NSEC_PER_SEC))
                dispatch_after(time, dispatch_get_main_queue(), {
                    let image = UIImage(imageLiteral: "Checkmark").imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
                    let imageView = UIImageView(image: image)
                    hud.customView = imageView
                    hud.mode = MBProgressHUDMode.CustomView
                    hud.label.text = "已是最新版本"
                    hud.hideAnimated(true, afterDelay: 1)
                })
            }))
        group2.settings.append(Setting(title: "帮助", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow"), block: {
            [unowned self] in
            let controller = HelpViewController()
            // 因为是自定义的 UITabBarItem 所以这里设置了也无效
//            controller.hidesBottomBarWhenPushed = false
            controller.navigationItem.title = "帮助"
            
            self.navigationController?.pushViewController(controller, animated: true)
            }))
        group2.settings.append(Setting(title: "分享", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow")))
        group2.settings.append(Setting(title: "查看消息", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow")))
        group2.settings.append(Setting(title: "产品推荐", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow"), block: {
            [unowned self] in
            let controller = ProductViewController(collectionViewLayout : UICollectionViewFlowLayout())
            controller.navigationItem.title = "产品推荐"
            self.navigationController?.pushViewController(controller, animated: true)
            }))
        group2.settings.append(Setting(title: "投信", titleImage: UIImage(imageLiteral: "handShake"), accessoryImage: UIImage(imageLiteral: "CellArrow")))
        self.settings.append(group2)
    }
    
}
